package com.itic.web.util;

public class HexText2 {
	

	
	static void t15(String name){  

	    byte[] src = string2bytes(name); 
	    
	    //生成16进制
		String hex = Toolkit.bytes2Hex(src);  
		//16进制转成byte[]
		byte[] src2 = Toolkit.hex2Bytes1(hex);
		
		//byte[]再转回String
		String str2 = bytes2string(src2);
		
		System.out.println("最后转回的字符串是"+str2);
	}
	static void t16(String hex){  
		
		//16进制转成byte[]
		byte[] src2 = Toolkit.hex2Bytes(hex);
		//byte[] 进行md5解密
		String kl = MD5Util.convertMD5(src2.toString());
		
		//byte[]再转回String
		//String str2 = bytes2string(string2bytes(kl));
		
		System.out.println("16进制转成的字符串是"+kl);
	}
	
	//String isoString = new String(bytes,"ISO-8859-1");
	//String srt2=new String(midbytes,"UTF-8");
	static String bytes2string(byte[] midbytes){
		String srt2=null;
		try {
			srt2=new String(midbytes,"UTF-8");
		} catch (Exception e) {
		}
		return srt2;
	}
	
	//byte[] midbytes=isoString.getBytes("UTF8");
	//为UTF8编码
	//byte[] isoret = srt2.getBytes("ISO-8859-1");
	static byte[] string2bytes(String srt3){
		byte[] isoret = null;
		 try {
			isoret = srt3.getBytes("UTF-8");
		 } catch (Exception e) {
		     }
		 return isoret;
	}
	
	
	public static void main(String[] args) {
		String str = "12345qwert";
		System.out.println("传入的字符串是"+str);
		t15(str);
	}

}
